import { defineStore } from 'pinia';

export const usePermissionStore = defineStore('permission', {
  state: () => ({
    permissions: [], // 存储用户权限标识
    routes: [],      // 动态路由
    whiteList: ['/pages/login/login'] // 白名单
  }),
  actions: {
    // 设置权限
    setPermissions(permissions) {
      this.permissions = permissions;
    },
    // 检查权限
    hasPermission(permission) {
      return this.permissions.includes(permission);
    },
    // 检查多个权限中的任意一个
    hasAnyPermission(permissions) {
      return permissions.some(perm => this.hasPermission(perm));
    },
    // 检查所有权限
    hasAllPermissions(permissions) {
      return permissions.every(perm => this.hasPermission(perm));
    }
  }
});